//
//  YCHEOJoinedTableViewCell.m
//  HeartWorldClient
//
//  Created by 董知樾 on 2016/11/16.
//  Copyright © 2016年 谭明权. All rights reserved.
//

#import "YCHEOJoinedTableViewCell.h"
#import "YCHEOPersonModel.h"

@interface YCHEOJoinedTableViewCell ()

@property (strong, nonatomic) UIView *contaierView;

@property (strong, nonatomic) UILabel *nameLabel;

@property (strong, nonatomic) UILabel *numberLabel;

@property (strong, nonatomic) UIButton *rightAreaBtn;

@property (strong, nonatomic) UILabel *statusLabel;

@end

@implementation YCHEOJoinedTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubviews];
    }
    return self;
}

- (void)createSubviews {
    //56
    _contaierView = [[UIView alloc]init];
    [self.contentView addSubview:_contaierView];
    _contaierView.backgroundColor = [UIColor whiteColor];
    _contaierView.layer.borderWidth = 0.5;
    _contaierView.layer.borderColor = [UIColor colorWithRGBValue:0xcccccc].CGColor;
    _contaierView.layer.masksToBounds = YES;
    [_contaierView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(UIEdgeInsetsMake(8, 10, 8, 10));
    }];
    
    _nameLabel = [[UILabel alloc]init];
    _nameLabel.font = [UIFont systemFontOfSize:14];
    _nameLabel.backgroundColor = [UIColor whiteColor];
    _nameLabel.layer.masksToBounds = YES;
    _nameLabel.textColor = [UIColor colorWithRGBValue:0x333333];
    [_contaierView addSubview:_nameLabel];
    [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(12);
        make.centerY.equalTo(_contaierView);
    }];
    
    CGFloat rightAreaW = 100;
    
    _numberLabel = [[UILabel alloc]init];
    _numberLabel.font = [UIFont systemFontOfSize:14];
    _numberLabel.textColor = [UIColor colorWithRGBValue:0x666666];
    _numberLabel.backgroundColor = [UIColor whiteColor];
    _numberLabel.layer.masksToBounds = YES;
    [_contaierView addSubview:_numberLabel];
    [_numberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.mas_equalTo(-rightAreaW);
        make.centerY.equalTo(_contaierView);
    }];
    
    UIView *line = [[UIView alloc]init];
    line.backgroundColor = [UIColor colorWithRGBValue:0x666666];
    [_contaierView addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(_numberLabel.mas_trailing).offset(10);
        make.size.mas_equalTo(CGSizeMake(0.5, 30));
        make.centerY.equalTo(_contaierView);
    }];
    
    _rightAreaBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [_rightAreaBtn addTarget:self action:@selector(didClickRightAreaBtn:) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:_rightAreaBtn];
    [_rightAreaBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.trailing.bottom.equalTo(self.contentView);
        make.width.mas_equalTo(rightAreaW);
    }];
    _rightAreaBtn.hidden = YES;
    
    _statusLabel = [[UILabel alloc]init];
    _statusLabel.font = [UIFont systemFontOfSize:14];
    _statusLabel.textColor = [UIColor colorWithRGBValue:0xFF8400];
    [_contaierView addSubview:_statusLabel];
    [_statusLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.mas_equalTo(-33);
        make.centerY.equalTo(_contaierView);
    }];
    
    UIImageView *arrowImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"message_arrow"]];
    [_contaierView addSubview:arrowImageView];
    [arrowImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(7, 14));
        make.trailing.mas_equalTo(-15);
        make.centerY.equalTo(_contaierView);
    }];
    
    _nameLabel.text = @"欧阳锋";
    _numberLabel.text = @"No.00158546";
    _statusLabel.text = @"观察期";
}

- (void)didClickRightAreaBtn:(UIButton *)btn {
    
}

- (void)setModel:(YCHEOPersonModel *)model {
    _model = model;
    
    _nameLabel.text = [NSString stringWithFormat:@"姓名:%@",model.personName];
    _numberLabel.text = [NSString stringWithFormat:@"余额:%@元",model.totalMoney];
    _statusLabel.text = model.bxStatus;
    
}

- (void)awakeFromNib {
    [super awakeFromNib];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}

@end
